<template>
  <Dropdown class="menu-container"
            trigger="click"
            @on-click="menuClick">
    {{ label }}
    <DropdownMenu v-if="menus.length > 0" slot="list">
      <DropdownItem v-for="(item, index) in menus"
                    :name="item.name"
                    :key="index">{{ item.label }}</DropdownItem>
    </DropdownMenu>
  </Dropdown>
</template>

<script>
export default {
  name: 'OperationMenu',
  props: {
    label: String,
    data: Object,
    menus: {
      type: Array,
      default: () => []
    }
  },
  methods: {
    menuClick(name) {
      this.$emit('menu-click', name, this.data);
    }
  }
}
</script>

<style scoped lang="less">
  .menu-container.ivu-dropdown /deep/ .ivu-dropdown-rel {
    padding: 14px 41px;
  }
</style>
